﻿package bdz.projects.lavender.doi.ui
{
	import bdz.common.events.*;
	import bdz.common.managers.NetStreamManager;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.media.Video;
	
	/**
	 * ...
	 * @author ...
	 */
	public class DOIVideoLayer extends MovieClip 
	{
		private var _nsmanager:NetStreamManager;
		private var _video:Video;
		private var _vw:Number;
		private var _vh:Number;
		private var _source:String;
		public function DOIVideoLayer(w:Number, h:Number, src:String) {
			_vh = h;
			_vw = w;
			_source = src;
			addEventListener(Event.ADDED_TO_STAGE, initializeComponent);
		}
		private function initializeComponent(evt:Event) :void {
			_video = new Video(_vw, _vh);
			addChild(_video);
			
			_nsmanager = new NetStreamManager();
			_nsmanager.addEventListener(NetStreamManagerEvent.LOAD_PROGRESS, onStreamLoadProgress);
			_nsmanager.addEventListener(NetStreamManagerEvent.LOAD_COMPLETE, onStreamLoadComplete);
			_nsmanager.vsource = _video;
			_nsmanager.source = _source;
			
			mouseEnabled = mouseChildren = false;
		}
		private function onStreamLoadProgress(evt:NetStreamManagerEvent):void {
			
		}
		private function onStreamLoadComplete(evt:NetStreamManagerEvent):void {
			_nsmanager.play();
		}
		public function clear():void {
			
		}
	}
	
}